package v1

import (
	"card/app/http/controllers/api"
	"card/app/logic"
	"card/app/requests"
	"card/pkg/response"
	"github.com/gin-gonic/gin"
)

type RoomController struct {
	api.BaseApiController
}

func (ctrl *RoomController) CreateRoom(c *gin.Context) {
	params := new(requests.RoomRequest)
	if err := requests.Validate(c, params, requests.RoomValidate); err != nil {
		response.Error(c, err)
		return
	}
	roomLogic := logic.NewCardRoom(c)
	str, err := roomLogic.CreateRoom(params)
	if err != nil {
		response.Error(c, err, "创建房间失败")
		return
	}
	response.Data(c, str, "创建房价成功")
}
